{extend name="layout" /}
{block name="head_meta"}
    <link rel="canonical" href="https://{$site_domain}{:get_full_url_by_uri($current_lang, 'lyrics/'. rawurlencode($lyric['title']))}" />
{/block}
{block name="content"}
<div class="container mx-auto px-4 py-8">
    <nav class="text-sm mb-6">
        <ol class="list-none p-0 inline-flex">
            <li class="flex items-center">
                <a href="{:get_full_url_by_uri($current_lang,'')}" class="text-purple-600 hover:text-purple-800">{$Think.lang.home}</a>
                <span class="mx-2 text-gray-500">/</span>
            </li>
            <li class="flex items-center">
                <a href="{:get_full_url_by_uri($current_lang,'list')}" class="text-purple-600 hover:text-purple-800">{$Think.lang.lyrics_list}</a>
                <span class="mx-2 text-gray-500">/</span>
            </li>
            <li class="text-gray-700 truncate">{$lyric.title}</li>
        </ol>
    </nav>
    
    <div class="bg-white rounded-lg shadow-lg overflow-hidden mb-6">
        <div class="md:flex">
            <div class="md:w-1/4 lg:w-1/5">
                {if !empty($lyric.cover_image)}
                <div class="h-48 md:h-full">
                    <img src="{$lyric.cover_image}" alt="{$lyric.title}" class="w-full h-full object-cover">
                </div>
                {else}
                <div class="h-48 md:h-full bg-gradient-to-r from-cyan-500 to-blue-600 flex items-center justify-center">
                    <div class="text-white text-center p-4">
                        <div class="text-3xl md:text-4xl mb-2"><i class="fas fa-music"></i></div>
                        <div class="text-sm md:text-base font-bold mb-1 line-clamp-2">{$lyric.title}</div>
                        <div class="text-xs md:text-sm text-cyan-100">{$lyric.artist}</div>
                    </div>
                </div>
                {/if}
            </div>
            
            <div class="p-4 md:p-6 md:w-3/4 lg:w-4/5">
                <div class="flex justify-between items-start mb-3">
                    <div class="flex-1 min-w-0">
                        <h1 class="text-2xl md:text-3xl font-bold mb-2 line-clamp-2">{$lyric.title_pinyin} ({$lyric.title})</h1>
                        <p class="text-lg md:text-xl text-gray-700 mb-3 line-clamp-1">{$lyric.artist_pinyin} ({$lyric.artist})</p>
                    </div>
                </div>
                
                <div class="flex flex-wrap items-center text-gray-600 text-sm gap-4">
                    <div class="flex items-center">
                        <i class="far fa-calendar-alt mr-2 text-cyan-500"></i> 
                        {:substr($lyric.created_at, 0, 10)}
                    </div>
                    <div class="flex items-center">
                        <i class="far fa-eye mr-2 text-blue-500"></i> 
                        {$lyric.views} {$Think.lang.views}
                    </div>
                    <div class="like-container" data-id="{$lyric.id}">
                        <button class="like-btn flex items-center text-gray-600 hover:text-red-500 transition duration-300 {$lyric.user_liked ? 'text-red-500' : ''}">
                            <i class="far fa-heart mr-2 {$lyric.user_liked ? 'fas' : 'far'} text-red-400"></i> 
                            <span class="like-count">{$lyric.likes}</span> {$Think.lang.likes}
                        </button>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="p-4 md:p-6 border-t border-gray-200">
            <div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-4 gap-3">
                <div class="flex items-center">
                    <h2 class="text-xl md:text-2xl font-bold mr-4">
                        <i class="fas fa-language text-cyan-500 mr-2"></i>
                        {$Think.lang.lyrics_content}
                    </h2>
                    <div class="flex items-center space-x-2 text-xs md:text-sm text-gray-500">
                    </div>
                </div>
                <div class="flex items-center space-x-2 md:space-x-3">
                    <button id="language-toggle" class="flex items-center space-x-1 md:space-x-2 bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 text-white transition-colors px-3 md:px-4 py-2 rounded-lg shadow-md hover:shadow-lg text-sm font-medium" data-mode="both">
                        <i class="fas fa-language"></i>
                        <span class="toggle-text">{$Think.lang.lang_toggle_both}</span>
                    </button>
                    <button class="download-btn flex items-center space-x-1 md:space-x-2 bg-cyan-500 hover:bg-cyan-600 text-white transition-colors px-3 md:px-4 py-2 rounded-lg shadow-md hover:shadow-lg text-sm">
                        <i class="fas fa-download"></i>
                        <span class="font-medium">{$Think.lang.download}</span>
                    </button>
                    <button class="print-btn flex items-center space-x-1 md:space-x-2 bg-blue-500 hover:bg-blue-600 text-white transition-colors px-3 md:px-4 py-2 rounded-lg shadow-md hover:shadow-lg text-sm">
                        <i class="fas fa-print"></i>
                        <span class="font-medium">{$Think.lang.print}</span>
                    </button>
                </div>
            </div>
            
            <div class="lyrics-content bg-gradient-to-br from-gray-50 to-blue-50 rounded-xl p-4 md:p-6 shadow-inner border border-gray-200" style="min-height: 300px;">
                {php}
                $lyric_content = json_decode($lyric['content'],true);
                {/php}
                    {foreach $lyric_content as $line}
                    <div class="lyrics-line hover:bg-blue-50 transition-colors py-1 mb-1">
                        <div class="original-text text-sm font-medium text-gray-600 leading-tight">
                            {$line.original}
                        </div>
                        <div class="pinyin-text text-xl text-blue-600 font-mono leading-tight tracking-wide">
                            {$line.pinyin}
                        </div>
                    </div>
                    {/foreach}
     
            </div>
            
            <div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-4 gap-3 mt-6 pt-4 border-t border-gray-200">
                <div class="flex items-center space-x-2 md:space-x-3">
                    <button id="language-toggle-bottom" class="flex items-center space-x-1 md:space-x-2 bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 text-white transition-colors px-3 md:px-4 py-2 rounded-lg shadow-md hover:shadow-lg text-sm font-medium" data-mode="both">
                        <i class="fas fa-language"></i>
                        <span class="toggle-text">{$Think.lang.lang_toggle_both}</span>
                    </button>
                    <button class="download-btn flex items-center space-x-1 md:space-x-2 bg-cyan-500 hover:bg-cyan-600 text-white transition-colors px-3 md:px-4 py-2 rounded-lg shadow-md hover:shadow-lg text-sm">
                        <i class="fas fa-download"></i>
                        <span class="font-medium">{$Think.lang.download}</span>
                    </button>
                    <button class="print-btn flex items-center space-x-1 md:space-x-2 bg-blue-500 hover:bg-blue-600 text-white transition-colors px-3 md:px-4 py-2 rounded-lg shadow-md hover:shadow-lg text-sm">
                        <i class="fas fa-print"></i>
                        <span class="font-medium">{$Think.lang.print}</span>
                    </button>
                </div>
            </div>
        </div>
    </div>
    
    <div class="mb-8">
        <h2 class="text-2xl font-bold mb-6">{$Think.lang.related_lyrics}</h2>
        <div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6">
            {foreach $related_lyrics as $related}
            <div class="bg-white rounded-xl shadow-md hover:shadow-xl transition-all duration-300 border border-gray-100 hover:border-cyan-200 group lyric-card">
                <a href="{:get_full_url_by_uri($current_lang,'lyrics/'. rawurlencode($related.title_uri))}" class="block p-5 h-full">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 bg-gradient-to-br from-cyan-500 to-blue-600 rounded-xl flex items-center justify-center text-white mr-3 flex-shrink-0 group-hover:from-cyan-600 group-hover:to-blue-700 transition-all">
                            <i class="fas fa-music text-sm"></i>
                        </div>
                        <div class="flex-1 min-w-0">
                            <h3 class="text-sm font-bold text-gray-800 group-hover:text-cyan-600 transition-colors truncate">{$related.title_pinyin} ({$related.title})</h3>
                            <p class="text-gray-600 text-xs truncate group-hover:text-cyan-500 transition-colors">{$related.artist_pinyin} ({$related.artist})</p>
                        </div>
                    </div>
                    
                    <div class="flex justify-between items-center pt-3 border-t border-gray-100">
                        <div class="text-gray-500 text-xs flex items-center">
                            <i class="far fa-eye mr-1"></i> 
                            {$related.views}
                        </div>
                        <span class="text-cyan-600 font-semibold text-xs flex items-center group-hover:translate-x-1 transition-transform">
                            {$Think.lang.lyrics} 
                            <i class="fas fa-arrow-right text-xs ml-1"></i>
                        </span>
                    </div>
                </a>
            </div>
            {/foreach}
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script>
    window.JS_LANGS = {$js_langs};
</script>
<script src="/static/js/detail.js?v=5"></script>
{/block} 